﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using DataBaseManager;
using Utilities.Common;
using BL.DataAccess;

namespace BL.Entities
{
    public class Movimiento
    {
        #region Propiedades

        public Int32 IdMovimientos { get; set; }
        public Profesionales Profesional { get; set; }
        public Double Monto { get; set; }
        public string Concepto { get; set; }
        public DateTime Fecha { get; set; }

        public string MontoGV {
            get {
                if (this.Monto >= 0)
                {
                    return this.Monto.ToString();
                }
                else { 
                    return "( " + this.Monto.ToString().Replace("-","") +" )";
                }
            }  
        
        }
        

        #endregion


        public int  Save() {

            ParameterManager pM = new ParameterManager();
            pM.Add("Matricula",this.Profesional.Matricula );
            pM.Add("Monto", this.Monto);
            pM.Add("Concepto", this.Concepto);
            pM.Add("Fecha", this.Fecha.ToString());

            DataBase.Current.Insert(Tables.Movimientos,pM);


            DataTable dt = DataBase.Current.ExecuteSQL("select Last(idMovimientos)  from Movimientos");

            return int.Parse(dt.Rows[0][0].ToString());

        }
    }
}
